<!DOCTYPE html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test_closure</title>
  <script type="text/javascript" src="misc/jquery.js"></script>
</head>
<body>
	<input type="button" value="更新" onclick="apply_submit();" />
</body>
   <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
	<script type="text/javascript">
	function apply_submit()
	{
	
				var sendData =1;
				var result=if_is_exited(sendData);
				alert(result());
				//alert(TC);

				function if_is_exited(sendData){ //这里使用闭包，访问到内部Ajax返回值
					var is_exited;
						function inner_ajax(){	
							$.ajax({
								async : false,
								dataType : "text",
								//data: total,
								data:"sendData="+sendData,
								url : "test_closure.php",
								type : 'POST',
								success : function(response) {	
									//alert(response);
									console.log(response);									
										is_exited=response;
										// alert(is_exited);										
								},
								error: function() { 
									alert('error'); 
								}
							});
							return is_exited;
						}
					return inner_ajax;
				}
			
	}		

	</script>
